package com.mlk.engSystem.api;

import com.mlk.core.util.ServerResponse;
import com.mlk.engSystem.po.EngPicBase;
import com.mlk.engSystem.po.EngPicBaseAddress;
import com.mlk.engSystem.service.EngPicBaseService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 图库
 */
@RequestMapping("/api/picBase")
@Controller
@ApiOperation("图库管理")
public class EngPicBaseAPI {

    @Autowired
    private EngPicBaseService engPicBaseService;

    @PostMapping("addEngPicBase")
    @ResponseBody
    @ApiOperation("增加图库")
    public ServerResponse addEngPicBase(EngPicBase engPicBase) {
        return engPicBaseService.addEngPicBase(engPicBase);
    }

    @PostMapping("addEngPicBaseAddress")
    @ResponseBody
    @ApiOperation("增加图片")
    public ServerResponse addEngPicBaseAddress(EngPicBaseAddress engPicBaseAddress, MultipartFile file) {
        return engPicBaseService.addEngPicBaseAddress(engPicBaseAddress, file);
    }

    @GetMapping("findAddEngPicBase")
    @ResponseBody
    @ApiOperation("查询图库")
    public ServerResponse findAddEngPicBase(String allParameters, Integer page, @RequestParam(defaultValue = "1") Integer limit) {
        return this.engPicBaseService.findAddEngPicBase(allParameters, page, limit);
    }

    /**
     * 删除图片
     *
     * @return
     */
    @ResponseBody
    @RequestMapping("delPic")
    public ServerResponse delPic(Integer id) {
        return this.engPicBaseService.delPic(id);
    }
}
